﻿@* ReSharper disable UnknownCssClass *@

@using OpusSuite.Helpers

@model OpusSuite.ViewModels.AccountAdmin.LogonModel

@{
    ViewBag.Title = "" ; @* OpusSuite.Globalisation.Resources.Logon.Login; *@
}
@Html.ValidationSummary(false)

<header>
<h1>@* @OpusSuite.Globalisation.Resources.Logon.Welcome *@</h1>
<br/>
<h2>@ViewBag.Title</h2>
</header>
<br/>
<br/>

@using (Html.BeginForm("Logon", "AccountAdmin", FormMethod.Post, new { id = "LogonForm" }))
{
    <fieldset>
        <legend></legend>
        
        <table>
        <tr>
        <td>
            @*<img src="@Url.Content("~/Content/login_logo.jpg")"alt="Login Logo" />*@
        </td>
        <td>
        <table class="table-editor">
        <tr>
            <td class="td-horiz-label">@Html.LabelFor(model => model.UserName, new { @class = "label-horiz" })</td>
            <td class="td-horiz-field">@Html.TextBoxFor(model => model.UserName, new { @class = "editor-horiz validate[required]" })</td>
        </tr>
        <tr>
            <td class="td-horiz-label">@Html.LabelFor(model => model.Password, new { @class = "label-horiz" })</td>
            <td class="td-horiz-field">@Html.PasswordFor(model => model.Password, new { @class = "editor-horiz validate[required]" })</td>
        </tr>
        <tr>
            <td class="td-horiz-label">@Html.LabelFor(model => model.DatabaseName, new { @class = "label-horiz" })</td>
            <td class="td-horiz-field">@Html.TextBoxFor(model => model.DatabaseName, new { @class = "editor-horiz validate[required]" })</td>
        </tr>
        <tr>
            <td class="td-horiz-label">@Html.LabelFor(model => model.ServerName, new { @class = "label-horiz" })</td>
            <td class="td-horiz-field">@Html.TextBoxFor(model => model.ServerName, new { @class = "editor-horiz validate[required]" })</td>
        </tr>
        <tr>
            <td class="td-horiz-label">@Html.LabelFor(model => model.ServerType, new { @class = "label-horiz" })</td>
            <td class="td-horiz-field">@Html.EnumDropDownListFor(model => model.ServerType, new { @class = "editor-horiz validate[required]" })</td>
        </tr>
        <tr>
            <td />
            <td><input id="login" type="submit" value="@OpusSuite.Globalisation.Resources.UICommon.Login" /></td>
            <td />
        </tr>
        </table>
        </td>
        </tr>
        </table>
    </fieldset>
}
@* ReSharper restore UnknownCssClass *@

<script type="text/javascript">
    $(document).ready(function () {
        $("#login").button();

        $("#UserName").opusTooltip({ title: '@OpusSuite.Globalisation.Resources.UICommon.Username', tip: '@OpusSuite.Globalisation.Resources.Logon.UserName_Tooltip' });
        $("#Password").opusTooltip({ title: '@OpusSuite.Globalisation.Resources.UICommon.Password', tip: '@OpusSuite.Globalisation.Resources.Logon.Password_Tooltip' });
        $("#DatabaseName").opusTooltip({ title: '@OpusSuite.Globalisation.Resources.UICommon.Database', tip: '@OpusSuite.Globalisation.Resources.Logon.DatabaseName_Tooltip' });
        $("#ServerName").opusTooltip({ title: '@OpusSuite.Globalisation.Resources.UICommon.Server', tip: '@OpusSuite.Globalisation.Resources.Logon.ServerName_Tooltip' });
        $("#ServerType").opusTooltip({ title: '@OpusSuite.Globalisation.Resources.UICommon.ServerType', tip: '@OpusSuite.Globalisation.Resources.Logon.ServerType_Tooltip' });
        $("#login").opusTooltip({ title: '@OpusSuite.Globalisation.Resources.UICommon.Login', tip: '@OpusSuite.Globalisation.Resources.Logon.Login_Tooltip' });

        $("#UserName").focus();

        $("#login").click(function (e) {
            e.preventDefault();

            $("form").validationEngine('attach', { promptPosition: "topRight", autoPositionUpdate: true });

            if ($("form").validationEngine('validate')) {
                $("#progressSpinner").progressSpinner('open', {
                    'title': '@OpusSuite.Globalisation.Resources.UICommon.ApplicationName' + ' - ' + '@(OpusSuite.Globalisation.Resources.Logon.LoggingIn)',
                    waitText: '@(OpusSuite.Globalisation.Resources.Logon.PleaseWait)'
                });

                $(document).oneTime(200, function () {
                    $("form").submit();
                });
            }
        });
    });
</script>
